//
//  RouteTableViewCell.m
//  课余时间
//
//  Created by zgr on 16/4/11.
//  Copyright © 2016年 张大少. All rights reserved.
//

#import "RouteTableViewCell.h"
#import "UIView+SDAutoLayout.h"
#import "UIImageView+WebCache.h"
@implementation RouteTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _image_url = [[UIImageView alloc]initWithFrame:CGRectMake(5, 3, KWIDTH - 10, (KWIDTH - 10) *446 / 670 )];
        [self.contentView addSubview:_image_url];
        _name = [UILabel new];
        [_image_url addSubview:_name];
        _name.textColor = [UIColor whiteColor];
        _plan = [UILabel new];
        [self.image_url addSubview:_plan];
        _plan.textColor = [UIColor whiteColor];
        _descrip = [UILabel new];
        [self.contentView addSubview:_descrip];
        
        _name.sd_layout
        .leftSpaceToView(_image_url,10)
        .topSpaceToView(_image_url,10)
        .rightSpaceToView(_image_url,10)
        .heightIs(30);
        
        _plan.sd_layout
        .leftSpaceToView(_image_url,10)
        .rightSpaceToView(_image_url,10)
        .bottomSpaceToView(_image_url,10)
        .heightIs(20);
        
        _descrip.sd_layout
        .leftSpaceToView(self.contentView,10)
        .topSpaceToView(_image_url,5)
        .rightSpaceToView(self.contentView,5)
        .autoHeightRatio(0);
        [self setupAutoHeightWithBottomView:_descrip bottomMargin:5];
        
        
        
    }
    return self;
}
-(void)setModel:(RouteModel *)model
{
    [_image_url sd_setImageWithURL:[NSURL URLWithString:model.image_url]];
    _name.text = model.name;
    _plan.text = [NSString stringWithFormat:@"%@天  %@个景点",model.plan_days_count,model.plan_nodes_count];
    _descrip.text = model.routeDescription;
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
